<?php



class DB
{

    /*variables*/
    protected $Link,$Result,$Numrows,$Fetch;
	
	protected $Server="localhost",$Username="root",$Password="",$db="book_market";

	
	
	
	       /***********************************************************/
          /*function constructor connect automatically to DB category*/
     	 /***********************************************************/

				   
    public function __construct ()
    
	{
	 
		//Link var contain connection
        $this->Link=mysqli_connect($this->Server,$this->Username,$this->Password);
        
        mysqli_select_db($this->Link,$this->db);
       
    }

	 

	       /***********************************************************/
          /*             function close connectio with DB            */
     	 /***********************************************************/
	 
     
    public function Disconnect()
    
	{
	 
        mysqli_close($this->Link);
		//echo 'disconnectd success';
    
	}
	 
	 


	 
	       /***********************************************************/
          /*  function Do Query Of Sql Statement Passed To Function  */
     	 /***********************************************************/
	 

	 
    public function Query($Sql)
    
	{
        $this->Result=mysqli_query($this->Link,$Sql);
		
		return $this->Result;
      
    }
	 
	 
	 

	       /***********************************************************/
          /*   function Check number of Results Returned From  DB    */
     	 /***********************************************************/
	 

    
	public function Check_Numrows()
    
	{
	 
        $this->Numrows=mysqli_num_rows($this->Result);
        $this->rows=array();
        for($x=0;$x<$this->Numrows;$x++)
        {
            $this->rows[]=mysqli_Fetch_assoc($this->Result);
        }
        return $this->Numrows;
    }
	 

	 

	       /***********************************************************/
          /*        function Fetch  Results Returned From DB         */
     	 /***********************************************************/
	 
	
    public function Do_Fetch()
    
	{
        $this->Fetch=mysqli_Fetch_array($this->Result);
		
		return $this->Fetch;
    }
     


}
?>




